package com.chandon.T02_functional;

import com.chandon.common.Cv;
import com.chandon.common.Role;

import java.util.function.Function;

/**
 * * jdk1.8中提供的函数式接口与输入输出的要求
 * *
 * *      Supplier:1个输出
 * *          Supplier<T>
 * * ------------------------------
 * *      Consumer:1个输入
 * *          Consumer<T>
 * *      BiConsumer:2个输入
 * *          BiConsumer<T,U>
 * * ------------------------------
 * *      Function:1个输入1个输出，类型不同
 * *          Function<T, R>
 * *
 * *      BiFunction:2个输入,1个输出，类型不同
 * *          BiFunction<T, U, R>
 * * ------------------------------
 * *      UnaryOperator:1个输入1个输出，类型相同
 * *          UnaryOperator<T> extends Function<T, T>
 * *
 * *      BinaryOperator:2个输入1个输出，类型相同
 * *         BinaryOperator<T> extends BiFunction<T,T,T>
 *
 * @author Dong
 * @version 1.0
 * @date 2021-04-14 1:57
 */

public class T03_TestFunction {
    public static void main(String[] args) {

        Cv cv0 = Cv.builder().age(17).name("asamiyui").scope(10).build();
        Role role0 = Role.builder().cv(cv0).name("yui").build();

        Function<Cv, String> f0 = cv -> cv.getName();
        Function<Cv, String> f1 = (cv) -> cv.getName();
        Function<Cv, String> f2 =cv -> { return cv.getName();};
        Function<Cv, String> f3 =(cv) -> { return cv.getName();};
        Function<Cv, String> f4 = Cv::getName;

        System.out.println(f0.apply(cv0));
        System.out.println(f1.apply(cv0));
        System.out.println(f2.apply(cv0));
        System.out.println(f3.apply(cv0));
    }

}
